<template>
  <div>
    <form>
      <label>姓名：</label>
      <input type="text" v-model="person.uname" /><br /><br />

      <label>年龄：</label>
      <input type="number" v-model="person.age" /><br /><br />

      <label>身高：</label>
      <input type="number" v-model="person.height" />(米)<br /><br />

      <label>体重：</label>
      <input type="number" v-model="person.weight" />(公斤)<br /><br />

      <label>病史：</label>
      <input type="text" v-model="person.worry" /><br /><br />
      <!--  -->
      <button @click.prevent="fn">诊断</button>
    </form>

    <p>
      患者 {{ person.formation }}的诊断结果：{{  person.level}}
    </p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      person: {
        uname: '',
        age: '',
        height: '',
        weight: '',
        worry: '',
       
        formation: '',
        level:''
      },
    }
  },
  methods: {
    fn() {
     let BMI = (this.person.weight /(this.person.height ^ 2) )
     console.log(BMI);
      if(BMI>=18.5 && BMI <24){
        this.person.level = '体重正常'
      }else if(BMI<18.5){
         this.person.level = '营养不良'
      }else if(BMI>= 25  &&BMI<30){
         this.person.level = '超重'
      }else{
        this.person.level = '肥胖'
      }
      /* this.person.formation = this.person.uname
      this.person.uname = ''
      this.person.age = ''
      this.person.height = ''
      this.person.weight = ''
      this.person.worry = '' */
    },
  },
}
</script>
